package com.songlanyun.modules.usergains.model;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
import com.songlanyun.common.drive.ValueObject;
import com.songlanyun.common.enums.DistributionConstant;
import com.songlanyun.common.enums.OrderConstant;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@ExcelTarget("userOrderGains")
@Data
public class UserOrderGainsVo implements ValueObject {


    @Excel(name = "商品名称", orderNum = "1", width = 30D)
    private String goodsTitle;

    @Excel(name = "商品规格", orderNum = "2", width = 15D)
    private String skuSetName;

    @Excel(name = "购买数量", orderNum = "3", width = 13D)
    private Integer number;

    @Excel(name = "最终商品单价", orderNum = "4", width = 13D)
    private BigDecimal realPrice;

    /**
     * 是否是代销
     */
    @Excel(name = "是否是代销", orderNum = "5", replace = {"非代销商品_false", "代销商品_true"}, width = 13D)
    private Boolean proxyGoods;


    @Excel(name = "订单编号", orderNum = "6", width = 15D)
    private String orderCode;

    @Excel(name = "订单状态", orderNum = "7", width = 13D)
    private String orderStatus;

    public String getOrderStatus() {
        if (settlement) {
            return "已结算";
        } else if (!ableSettlement) {
            return "未完成";
        } else {
            return "已完成，未结算";
        }
    }

    /**
     * 应该结算时间
     */
    @Excel(name = "应该结算时间", width = 15D, databaseFormat = "yyyyMMddHHmmss", format = "yyyy-MM-dd HH:mm", orderNum = "8")
    private Date shouldSettlementTime;

    @Excel(name = "分佣会员手机号", orderNum = "9", width = 15D)
    private String distributionUserMobile;


    @Excel(name = "分润初始值", orderNum = "10", width = 13D)
    private BigDecimal gains;

    @Excel(name = "售后影响值", orderNum = "11", width = 13D)
    private BigDecimal refundDeduct;

    @Excel(name = "分润最终值", orderNum = "12", width = 13D)
    private BigDecimal ableGains;

    /**
     * 0一二级分佣、182分佣、2750礼包分佣、3差价分佣、4分享分佣\
     */
    @Excel(name = "分佣算法", width = 13D, replace = {"一二级分佣_0", "282分佣_1", "6750礼包分佣_2", "差价分佣_3", "分享分佣_4"}, orderNum = "13")
    private int distributionComputer;

    @Excel(name = "分佣说明", orderNum = "14", width = 30D)
    private String envRemark;

    @Excel(name = "打款说明", orderNum = "14", width = 30D)
    private String giveRemark;

    public void setGiveRemark() {
        if (this.distributionComputer == 0 || this.distributionComputer == 4) {
            this.giveRemark ="无需打款，结算完成后入会员佣金";
            this.bankName = "";
            this.cardNum = "";
            this.realName = "";
            this.reservedMobile = "";
        }
        else
        {
            this.giveRemark ="结算完成后，需手动打款到会员帐户";
        }
    }

    @Excel(name = "收款银行", orderNum = "15", width = 15D)
    private String bankName;

    @Excel(name = "银行卡号", orderNum = "16", width = 15D)
    private String cardNum;

    @Excel(name = "开户姓名", orderNum = "17", width = 13D)
    private String realName;

    @Excel(name = "预留手机号", orderNum = "18", width = 13D)
    private String reservedMobile;

    /**
     * 渠道类型 0系统自动,1 微信小程序，2 APP（订单来源）
     */

    private int channelType;
    /**
     * 0普通商品，1服务商品
     */
    private int goodsType;

    /**
     * 营销活动类型
     */
    private int marketingType;

    /**
     * 支付时间
     */
    private Date createTime;


    /**
     * 商品总价
     */

    private BigDecimal totalRealPrice;

    /**
     * 首单优惠分摊
     */
    private BigDecimal firstOrderReduced;


    /**
     * 礼包类型  0非礼包，1.礼包282，2.礼包6750
     */
    private int giftType;


    private Long id;
    /**
     * 订单id
     */
    private Long orderId;

    /**
     * 子订单编号
     */
    private Long childOrderId;
    /**
     * 商品id
     */
    private Long goodsId;
    /**
     * 商家id
     */
    private Long shopId;

    /**
     * 商品规格编码
     */
    private String skuBarCode;

    /**
     * 商家名称
     */
    private String shopName;

    /**
     * 是否存在退款
     */
    private Boolean existsRefund;

    private Date updateTime;
    /**
     * 下单会员id
     */
    private Long userId;
    /**
     * 商品短标题
     */
    private String shortGoodsTitle;

    /**
     * 原规格销售价
     */
    private BigDecimal salePrice;
    /**
     * 商品图片
     */
    private String goodsImg;

    /**
     * 出货方式（0物流，1自提）
     */
    private int shipmentMode;
    /**
     * 单位
     */
    private String unit;

    /**
     * 规格的Hash编码，方便去对应和查找
     */
    private String skuHashCode;


    /**
     * 总优惠多少钱
     */
    private BigDecimal totalReduced;

    /**
     * 单位成本
     */
    private BigDecimal cost;
    /**
     * 总成本
     */
    private BigDecimal totalCost;
    /**
     * 单品标识
     */
    private Long singleGoodsId;


    /**
     * 结算时间
     */
    private Date settlementTime;
    /**
     * 是否已结算
     */
    private Boolean settlement;
    /**
     * 分佣会员id
     */
    private Long distributionUserId;


    /**
     * 分佣等级code
     */
    private String distributionUserRoleCode;
    /**
     * 分佣等级名称
     */
    private String distributionUserRoleName;
    /**
     * 0,自营商品1级分佣，
     * <p>
     * 1,自营商品2级分佣，
     * <p>
     * 2,代销商品小程序分佣282上一级分佣
     * <p>
     * 3,代销商品小程序分佣282上两级分佣
     * <p>
     * 4,代销商品小程序分佣282最近的市代分佣
     * <p>
     * 5,代销商品小程序分佣6750，直接上级平台合伙人分佣
     * 6,代销商品小程序分佣6750，间接上级县级代理或市级代理分佣
     * 7,代销商品小程序分佣6750，直接上级县级代理或市级代理分佣
     * 8,代销商品小程序分佣6750，县级代理或市级代理10%分佣
     * 9,代销商品小程序分佣6750，县级代理或市级代理7%分佣
     * <p>
     * 10,代销商品小程序差价分佣，一级差价分佣
     * 11,代销商品小程序差价分佣，二级差价分佣
     * 12,代销商品小程序差价分佣，县级代理或市级代理10%分佣
     * 13,代销商品小程序差价分佣，县级代理或市级代理7%分佣
     */
    private DistributionConstant.DistributionType distributionType;


    /**
     * 结算说明
     */
    private String settlementRemark;
    /**
     * 是否可以结算了
     */
    private Boolean ableSettlement;

    /**
     * 商家所得记录id
     */
    private Long shopGainsId;


}
